<?php

/**
 * @author christian
 * @copyright 2011
 */

//echo "registrar ....";
//echo getcwd();
//echo basename(getcwd());
$ruta=$_SERVER['DOCUMENT_ROOT']."/viventura"."/MDTour";
include_once("$ruta/conf/CConfig.php");
include_once("$ruta/elements/head.tpl");
include_once("$ruta/MDItinerary/MDItineraryEditDraw.php");
include_once("$ruta/MDTourGeneral/CTourEditDraw.php");
include_once("$ruta/MDTourGeneral/CDrawPageReg.php");
include_once("$ruta/view/CDrawMenuTour.php");
include_once("$ruta/star.php");




if (!isset($_POST['idPackTour'])) {$_POST['idPackTour'] = "NULL"; }
if (!isset($_POST['type'])) {$_POST['type'] = "0"; }
if (!isset($_GET['full'])) {$_GET['full'] = "NULL"; }
if (!isset($_POST['forday'])) {$_POST['forday'] = "NULL"; }

$forday = $_POST['forday'];
$full = $_GET['full'];
$idTourTrack = $_POST['type'];
$idPackTour=$_POST['idPackTour'];


$items=array("Regresar"=>"CSmallDefinePack.php","Nuevo paquete"=>"g","Ver paquetes"=>"g","Otra"=>"g");

CDrawMenuTour::getInstance()->setMenu($items);
CDrawMenuTour::getInstance()->rigth_side_begin();//empieza lado derecho 
CDrawMenuTour::getInstance()->DrawDivAdBegin("content_area_user_title","1");echo "<h1>Destino Sur</h1>";
CDrawMenuTour::getInstance()->DrawDivAdEnd();


$action="CManageTrack.php";$name="formulario_registro";$method="post";$NAME="Itinerario";
MDItineraryEditDraw::getInstance()->DrawHead($action,$name,$method,$NAME);

CTourEditDraw::getInstance()->HiddenValue($idTourTrack,"idTourTrack");
	
if($full==1){
    
    CDrawPageReg::getInstance()->DrawSelectDependence();

    
}

elseif($idTourTrack==0){
    
     $ini = "select DateBegTour from pack_has_tour where idPackTour= $idPackTour";
    
     $ini_tracking = CModelo::getInstance()->getData($ini);
     
       foreach($ini_tracking as $r=>$c){
            $table = $c;
            foreach($table as $r2=>$c2){
                $NewBegTourTracks= $c2;
            }
       }
       
       $FirstTrack = CDrawPageReg::getInstance()->aphp($NewBegTourTracks);
       
       
       $campos=array("idTrack"=>"idTrack","DescTrack"=>"DescTrack");
       CDrawPageReg::getInstance()->DrawSelect("track",$campos,"Track","idTrack");
       
       CDrawPageReg::getInstance()->DrawReadOnly("DateBegTrack","Fecha de inicio del track",$FirstTrack);
       CDrawPageReg::getInstance()->DateMin("Fecha final del track","DateEndTrack",$FirstTrack);
       MDItineraryEditDraw::getInstance()->HiddenValue(0,"action");
     
     }

else {
    
    
     $campos=array("idTrack"=>"idTrack","DescTrack"=>"DescTrack");
         CDrawPageReg::getInstance()->DrawSelect("track",$campos,"Track","idTrack");
       
    $order = "Select OrdTrack, DateEndTrack from tour_has_track where idTourTrack=$idTourTrack";
    $table = CModelo::getInstance()->getData($order);
    
 
    foreach($table as $c=>$r ){
        $table1 = $r ;
        foreach($table1 as $c1 => $r1 ){
            $OrdAndEnd[]=$r1;
        }
        }
    
    CDrawPageReg::getInstance()->DrawReadOnly("OrdTrack","Orden",$OrdAndEnd[0]);
    CDrawPageReg::getInstance()->DrawReadOnly("DateBegTrack","Inicio del track",$OrdAndEnd[1]);
    
    $nuevo =   CDrawPageReg::getInstance()->aphp($OrdAndEnd[1]);
    
    CDrawPageReg::getInstance()->DateMin("Fin del track","DateEndTrack",$nuevo);
    
    $action=1;
    echo $action;
    MDItineraryEditDraw::getInstance()->HiddenValue($action,"action");  
    CDrawPageReg::getInstance()->HiddenValue($OrdAndEnd[0],"OrdTrack");
    CDrawPageReg::getInstance()->HiddenValue($OrdAndEnd[1],"DateBegTrack");
    
   
   
}

MDItineraryEditDraw::getInstance()->HiddenValue($idPackTour,"idPackTour");   
   
MDItineraryEditDraw::getInstance()->DrawSubmmit("Actualizar");
MDItineraryEditDraw::getInstance()->DrawFoot();
include_once("$ruta/elements/foot.tpl");


?>



